package main.java.IO;

/* 将message.txt文件中的内容进行反序列化 */
import org.apache.logging.log4j.message.Message;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

public class ObjectInputStreamDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //构建流对象
        ObjectInputStream ois =
                new ObjectInputStream(
                      new FileInputStream("Message.txt")
                );
        //读取对象(反序列化-先读出来的是字节，然后将字节转换对象)
        Message msg = (Message) ois.readObject();
        //输出对象
        System.out.println(msg);
        //关闭流
        ois.close();
    }
}
